# choice = input("输入1 表示认真学习 输入2 表示躺平摆烂")
# while(True):
#     if choice == "1":
#         print("会找到工作")
#         break
#     elif choice == "2":
#         print("你可能毕业就失业了!")
#         break
#     else:
#         print("输入有误")
#         break


# a = int(input("请输入一个数字："))
# if a % 2 == 0:
#     print("偶数")
# else:
#     print("奇数")
#
# c = input()
# print(type(c))

# year = int(input("请输入一个数字："))
# if year % 100 == 0:
#     if year % 400 == 0:
#         print("闰年")
#     else:
#         print("平年")
# else:
#     if year % 4 == 0:
#         print("闰年")
#     else:
#         print("平年")

# year = int(input("请输入一个数字"))
# if (year % 100 != 0 and year % 4 == 0) or year % 400 == 0:
#     print("闰年")
# else:
#     print("平年")

# n = 1
# while n <= 5:
#     a = int(input("请输入一个整数"))
#     if a % 2 == 0:
#         print("hello")
#     else:
#         pass
# n += 1


#
# num = 1
# sum = 0
# while num <= 5:
#     faulthandler = 1
#     i = 1
#     while i <= num:
#         faulthandler *= i
#         i += 1
#     sum += faulthandler
#     num += 1
# print(sum)
#

# for i in range(2,12,2):
#     print(i)

# sum = 0
# for i in range(1,101):
#     sum += i
#
# print(sum)


# sum = 0
# for i in range(1,101):
#     sum += i
# print(sum)
#
# def calcSum(beg, end):
#         sum = 0
#         for i in range(beg, end + 1):
#             sum += i
#         print(sum)
#
# calcSum(1,100)
#
# def test(a):
#     print(a)
#
# test(10)
# test('a')
# test("hello python")
# test(True)
#


def calcsum(beg,end):
    sum  = 0
    for i in range(beg,end+1):
        sum += i
    return sum

ret = calcsum(1,100)
print(ret)

def isOdd(num):
    if(num % 2 == 0):
        return False
    else:
        return True

print(isOdd(4))
print(isOdd(5))

# 一个函数可以返回一个 或者 多个返回值
def getpoint():
    x = 10
    y = 20
    return x,y

# a,b = getpoint()
# print(a)
# print(b)

_,b = getpoint()
print(b)

a,_ = getpoint()
print(a)
#
# x = 20
# def test():
#     global x
#     x = 20
#     print(f'函数内部 x = {x}')
#
# test()
# print(f'函数内部 x = {x}')



def add(x=3,y = 5,debug = False):
    if debug:
        print(f'调试信息: x={x}, y={y}')
    return x + y

print(add(10,20))
print(add(10,20,True))
print(add())

# alist = [ ]

# # alist = list()
# print(type(alist))
# print(type(list()))

# alist = [1,2,3,4]
# print(alist)
#
# alist1 = [1,'hello',True]
# print(alist1)
#
# print(alist)
# print(alist[2])
# alist[2] = 100
# print(alist)
# print(alist[2])

# print(alist[1000])


# 切片  [) 左闭右开
# alist = [1,2,3,4]
# # 2 3
# print(alist[1:3])
# # 2 3 4
# print(alist[1:])
# # 1 2 3
# print(alist[:-1])
# # 1 2 3 4
# print(alist[:])

# 切片操作可以指定步长
# alist = [1,2,3,4,5,6,7,8,9]
# print(alist[::1])
# print(alist[::2])
# print(alist[::3])
# print(alist[::4])
#
# print(alist[:5:2])

#
# alist = [1,2,3,4]
# for elem in alist:
#     print(elem)
#
# for i in range(0,len(alist)):
#     print(alist[i])
#
# print(len(alist))

# alist = [1,2,3,4]
# i = 0
# while i < len(alist):
#     print(alist[i])
#     i += 1
#
# alist.append('hello')
# print(alist)
#
# alist.insert(2,100)
# print(alist)
#
# # in 操作符，判定元素是否存在列表中，返回值是bool
# print(2 in alist)
# print(10 in alist)
# print(100 in alist)
#
#


# alist = [1,2,3,4]
# print(alist.index(2))
# print(alist.index(3))
# print(alist.index(4))
#

# alist = [1,2,3,4]
# alist.pop()
# print(alist)
#
# alist.append(123)
# alist.append(100)
#
# alist.pop(-1)
# print(alist)
#
# alist.remove(2)
# print(alist)


alist = [1,2,3,4]
blist = [5,6,7]
# + 会生成一个新的列表，不会影响到原来的列表
print(alist + blist)
print(alist)
print(blist)


# extend 会将将blist的列表拼接到alist中，会修改alist的值，不会修改blist的值
alist.extend(blist)
print(alist)
print(blist)


# 元组 不能修改里面的元素，列表可以修改里面的元素
atuple = ( )
atuple = tuple()
print(atuple)
print(type(tuple()))

def getpoint():
    return 10,20

result = getpoint()
print(type(result))

a = { }
b = dict()

print(type(a))
print(type(b))

student = { 'id': 1,'name':'zhangsan'}
print(student)

print('id' in student)
print('name' in student)
print('score' in student)

print(student['id'])
print(student['name'])

# 如果key 不存在，会创建新的key 并且赋值
student['socre'] = 100
print(student)

student['socre'] = 10
print(student)

student.pop('id')
print(student)

for key in student:
    print(key,student[key])

print(student.keys())

student['id'] = 1

print(student.values())

# items 会取出所有的键值对
# print(student.items())
#
# print(hash(0))
# print(hash(3.14))
# print(hash('hello'))
# print(hash(True))
# print(hash())

# 列表无法计算hash
# error : TypeError: hash() takes exactly one argument (0 given)
# print(hash([1,2,3]))

# f = open('F:/gitee/2024/test/py_test.txt','w')
# f.write('hello')
# f.close()

# f = open('F:/gitee/2024/test/py_test.txt','r')
# f.write('hello')
# f.close()
#

#
# f = open('F:/gitee/2024/test/py_test.txt','a')
# f.write(' world')
# f.close()


import datetime

date1 = datetime.datetime(2025,1,19)
date2 = datetime.datetime(2024,1,19)
print(date1 - date2)




